
const Story = require('../models/story')
const Person = require('../models/person')

console.log(Story,Person);
let personObj = {
    _id: '123',
    name: 'Ian Fleming',
    age: 50
}
// Person.create(personObj)
// Story.create({
//     title: 'Casino Royale',
//     author: '123'
// })
// author.save(function (err) {
//     // if (err) return handleError(err);

//     var story1 = new Story({
//         title: 'Casino Royale',
//         author: author._id    // assign the _id from the person
//     });

//     story1.save(function (err) {
//         // if (err) return handleError(err);
//         // thats it!
//     });
// });
Story.
  findOne({ title: 'Casino Royale' }).
  populate('author').
  exec(function (err, story) {
      console.log(story);
    // prints "The author is Ian Fleming"
  });